//
//  YHShoppingMallBuyAddressCell.m
//  YHApp
//
//  Created by -- on 2021/8/21.
//

#import "HAShoppingMallBuyAddressCell.h"
#import "HAAddressMo.h"

@interface HAShoppingMallBuyAddressCell ()

/***/
@property (nonatomic, strong) UIView *mainView;
/***/
@property (nonatomic, strong) UIImageView *iconImgView;
/***/
@property (nonatomic, strong) UILabel *nameLabel;
/***/
@property (nonatomic, strong) UILabel *addressLabel;
/***/
@property (nonatomic, strong) UIImageView *rimgV;


@end

@implementation HAShoppingMallBuyAddressCell


-(void)setModel:(HAAddressMo *)model {
    _model = model;
    
    if (_model) {
        self.nameLabel.text = [NSString stringWithFormat:@"%@ %@",_model.surname,_model.mobile];
        self.addressLabel.text = [NSString stringWithFormat:@"%@ %@",_model.region,_model.address];
    }else {
        self.nameLabel.text = @"您还没有添加收货地址，去添加";
        self.addressLabel.text = @"";
    }

}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.contentView.backgroundColor = [UIColor khaBGColor];
    
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-10);
    }];
    
    [self.rimgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_offset(5);
        make.height.mas_offset(10);
        make.top.mas_equalTo(35);
        make.right.mas_equalTo(-20);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(self.rimgV.mas_left).offset(-10);
        make.top.mas_equalTo(15);
    }];
    
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(self.rimgV.mas_left).offset(-10);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
    }];
    
}

- (UIView *)mainView
{
    if (!_mainView) {
        _mainView = [UIView ha_createView];
        _mainView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_mainView];
    }
    return _mainView;
}

- (UIImageView *)iconImgView
{
    if (!_iconImgView) {
        _iconImgView = [UIImageView ha_createImageView];
        _iconImgView.image = [UIImage imageNamed:@""];
        [self.mainView addSubview:_iconImgView];
    }
    return _iconImgView;
}

- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [UILabel ha_NLabelWithFont:16 textColor:@"#111A34" text:@"" alignment:0];
        [self.mainView addSubview:_nameLabel];

    }
    return _nameLabel;
}

- (UILabel *)addressLabel
{
    if (!_addressLabel) {
        _addressLabel = [UILabel ha_NLabelWithFont:12 textColor:@"#898b9c" text:@"" alignment:0];
        _addressLabel.numberOfLines = 0;
        [self.mainView addSubview:_addressLabel];
    }
    return _addressLabel;
}

- (UIImageView *)rimgV
{
    if (!_rimgV) {
        _rimgV = [UIImageView ha_createImageView];
        _rimgV.image= [UIImage imageNamed:@"ic_cell_more"];
        [self.mainView addSubview:_rimgV];
    }
    return _rimgV;
}

@end
